<template>
	<view class="weui-cell" :class="{'uni-list-item--disabled':(disabled === true || disabled === 'true'),'weui-cell_access':(showArrow === true)}" @click="onClick">
		<view class="weui-cell__hd" v-if="thumb">
			<image class="uni-list-item__icon-img" :src="thumb"></image>
		</view>
		<view class="weui-cell__hd" v-else-if="extraIcon">
			<uni-icon :color="extraIcon.color" :size="extraIcon.size" :type="extraIcon.type" :class="extraIcon.class" right="0"></uni-icon>
		</view>
		<view class="weui-cell__bd">
			{{title}}
			<!-- <view class="uni-list-item__content-note" v-if="note">{{note}}</view> -->
		</view>
		<slot></slot>
		<view class="weui-cell__ft" v-if="showBadge === true || showBadge === 'true' || showArrow === true || showArrow === 'true'||showSwitch === true || showSwitch === 'true'">
			<text v-if="rightText" :style="{'color': rightColor}">{{rightText}}</text>
			<uni-badge v-if="showBadge === true || showBadge === 'true'" :type="badgeType" :text="badgeText"></uni-badge>
			<switch v-if="showSwitch === true || showSwitch === 'true'" :disabled='disabled' :checked="switchChecked" @change="onSwitchChange" />
		</view>
	</view>
</template>

<script>
	import uniIcon from '../uni-icon/uni-icon.vue'
	import uniBadge from '../uni-badge/uni-badge.vue'
	export default {
		name: 'uni-list-item',
		components: {
			uniIcon,
			uniBadge
		},
		data() {
			return {

			};
		},
		props: {
			title: String, //列表标题
			note: String, //列表描述
			disabled: { //是否禁用
				type: [Boolean, String],
				default: false
			},
			showArrow: { //是否显示箭头
				type: [Boolean, String],
				default: true
			},
			showBadge: { //是否显示数字角标
				type: [Boolean, String],
				default: false
			},
			showSwitch: { //是否显示Switch
				type: [Boolean, String],
				default: false
			},
			switchChecked: { //Switch是否被选中
				type: [Boolean, String],
				default: false
			},
			rightText: String, //右边文字
			rightColor: {       //右边文字颜色
				type:String,
				default:"#999999"
			},
			badgeText: String, //badge内容
			badgeType: { //badge类型
				type: String,
				default: 'success'
			},
			thumb: String, //缩略图
			extraIcon: Object
		},
		methods: {
			onClick() {
				this.$emit('click')
			},
			onSwitchChange(e) {
				this.$emit('switchChange', e.detail)
			}
		}
	}
</script>

<style>
	@charset "UTF-8";
	
</style>